package com.hanxiaozhang.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author hanxinghua
 * @create 2022/9/8
 * @since 1.0.0
 */
@Component
public class RedisUtil {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public Long incr(String key, Long num) {
        return stringRedisTemplate.opsForValue().increment(key, num);
    }

    public void expire(String key, Long timeout) {
        stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
    }


}
